<template>
    <div class="playMonenConfirm">
        <div class="title">打款审核</div>
        <div class="playMonenConfirm-content">
            <label class="filterText">业务员</label>
            <el-input class="order-input-short" placeholder="请输入姓名" v-model="filter.salemanName"></el-input>
            <!-- <label class="filterText">业务部门</label> -->
            <!-- <el-autocomplete class="creditList-input-selemanName inline-input" v-model="filter.saleDep" placeholder="请输入业务部门"></el-autocomplete> -->
            <label class="filterText">申请时间</label>
            <el-date-picker v-model="filter.time" type="daterange" placeholder="选择申请时间">
            </el-date-picker>
            <el-button class="filter-button-search" type="primary" icon="search" @click="search">搜索</el-button>
            <p/>
            <el-table class="playMonenConfirm-table" :data="tableData" style="width: 100%" empty-text="暂无搜索结果" @selection-change="handleSelectionChange" @filter-change="filterChange">
                <el-table-column prop="orderNo" label="订单编号" width="180">
                </el-table-column>
                <el-table-column prop="customerName" label="姓名" width="120">
                </el-table-column>
                <el-table-column prop="carType" label="车型" width="120">
                </el-table-column>
                <el-table-column prop="deptName" label="业务部门" width="120">
                </el-table-column>
                <el-table-column prop="staffName" label="业务员" width="120">
                </el-table-column>
                <el-table-column prop="bank" label="贷款银行" :filters="$store.state.bank" filter-placement="bottom-end" width="120">
                </el-table-column>
                <el-table-column prop="loan" label="贷款金额" width="120">
                </el-table-column>
                <el-table-column prop="gmtCreate" label="打款申请时间" sortable width="180">
                </el-table-column>
                <el-table-column fixed="right" label="操作" width="80">
                    <template scope="scope">
                        <el-button type="text" size="small">
                            <router-link :to="{path:'/playMonenConfirmDeal?orderNo='+scope.row.orderNo+'&flowNodeId='+scope.row.flowNodeId+'&taskId='+scope.row.taskId+'&bizType='+scope.row.bizType+'&annexBatchNo='+scope.row.annexBatchNo+'&customerIdCard='+scope.row.customerIdCard+'&applyType='+scope.row.applyType}">审核</router-link>
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="playMonenConfirm-pagination">
                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="tablePage.page" :page-sizes="[10, 20, 30, 40]" :page-size="tablePage.num" layout="sizes, prev, pager, next" :page-count="tablePage.pager">
                </el-pagination>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    name: 'playMonenConfirm',
    components: {},
    data() {
        return {

            filter: {
                time: [],
                text: '',
                status: '',
                salemanName: '', //业务员名称
                salemanNameList: [
                    { value: '名称1' },
                    { value: '名称2' }
                ],
                bankList: [],
                bank: ''
            },
            tableData: [],
            multipleSelection: [],
            tablePage: {
                pager: 1, //总页数
                page: 1, //当前页数
                num: 10, //每页条数
            }
        }
    },
    methods: {
        filterChange(data) {
            for (let i in data) {
                switch (i) {
                    case 'bank':
                        this.filter.bank = data[i][data[i].length - 1];
                        this.filter.bankList = data[i];
                        break;
                }
            }

            this.search();
        },
        handleSelectionChange(val) {
            console.log(val.length);
            this.multipleSelection = val;
            if (val.length < 2) {
                this.buttonShow = false;
            } else {
                this.buttonShow = true;
            }


        },
        getSalemanNameList(queryString, cb) {
            cb(this.filter.salemanNameList);
        },
        filterTag(value, row) {
            // this.status = this.filter.statusList[value];
            // return row.status === value;
            this.search();
        },
        info(index, rows) {
            console.log(rows);
        },
        handleSizeChange(val) {
            console.log(`每页 ${val} 条`);
            this.tablePage.num = val;
            this.search();
        },
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
            this.tablePage.page = val;
            this.search();
        },
        deleFilterText() {
            this.filter.text = '';
        },
        search() {
            console.log(this.filter.time);
            let param = {
                gmtCreateBegin: this.filter.time[0] ? this.$libs.formatDate(this.filter.time[0]) : '',
                gmtCreateEnd: this.filter.time[1] ? this.$libs.formatDate(this.filter.time[1]) : '',
                pageNo: this.tablePage.page,
                pageSize: this.tablePage.num,
                keyword: this.filter.text,
                loanBankId: this.filter.bankList.length > 1 ? '' : this.filter.bank,
                loanBankIdList: this.filter.bankList.length > 1 ? this.filter.bankList.join('%2C') : '',
                staffName: this.filter.salemanName
            };
            this.$http.get(this.$libs.getUrlSplit("/audit/list", param)).then((response) => {
                console.log(response);
                if (response.data.success) {
                    let that = this;
                    that.tableData = [];
                    that.tablePage.pager = response.data.totalPage;
                    that.tablePage.page = response.data.pageNo;
                    that.tablePage.num = response.data.pageSize;
                    $.each(response.data.data, function(index, el) {
                        that.tableData.push({
                            orderNo: el.orderNo,
                            customerName: el.customerName,
                            customerIdCard: el.customerIdCard,
                            carType: el.carModel,
                            bank: el.loanBankName,
                            loan: el.loanAmount,
                            deptName: el.deptName,
                            staffName: el.staffName,
                            gmtCreate: el.gmtCreate.substring(0, 10),
                            flowNodeId: el.flowNodeId,
                            bizType: el.bizChannel,
                            taskId: el.taskId,
                            annexBatchNo: el.annexBatchNo,
                            applyType: el.applyType
                        })
                    });
                }
            }).catch((error) => {});

        },
    },
    mounted() {
        this.search();
        this.$store.commit('bank', this);
    }
}

</script>
<style lang="scss" scoped>
.playMonenConfirm {
    padding: 10px 16px;

    .title {
        color: #99A9BF;
        font-size: 14px;
        line-height: 18px;
        margin: 8px 0px 10px 0px;
    }
    .playMonenConfirm-content {
        background: #fff;
        position: fixed;
        top: 96px;
        bottom: 10px;
        left: 216px;
        right: 16px;
        overflow: auto;
        padding: 20px;
        .filterText {
            font-size: 14px;
            color: #475669;
            margin: 10px 5px 0px 30px;
        }
        .playMonenConfirm-hr {
            margin: 20px 0px 30px 0px;
            background: #D3DCE6;
        }
        .playMonenConfirm-input-selemanName {
            width: 190px;
            margin-bottom: 10px;
            .playMonenConfirm-input-name {
                width: 90px;
            }
        }
        .playMonenConfirm-input-filter {
            width: 285px;
        }
        .filter-button-search {
            margin-left: 30px;
        }
        .playMonenConfirm-table {
            margin: 20px 0px;
        }
        .playMonenConfirm-pagination {
            text-align: center;
        }
        .order-input-short {
            width: 150px;
        }
        a {
            color: #20a0ff;
        }
    }
}

</style>
